package org.springblade.modules.admin.controller.feishu;

import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.modules.admin.service.UserPerformanceMonthService;
import org.springblade.modules.admin.service.feishu.IFeiShuElevatorService;
import org.springblade.modules.admin.service.feishu.IFeiShuPartsService;
import org.springblade.modules.admin.task.feishu.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * 飞书文档控制器
 * @author: Sharry
 * @createTime: 2023-12-27 9:44
 * @version: Version-1.0
 */
@RestController
@AllArgsConstructor
@RequestMapping("/admin/feishu")
@Api(value = "/admin/feishu", tags = "飞书文档控制器")
public class FeiShuDocumentController {

	@Autowired
	private FeiShuDocumentJob job;

	@Autowired
	private GalaxyElevatorTrackJob track;

	@Autowired
	private FeiShuDocumentPool pool;

	@Autowired
	private GalaxyElevatorNumsJob elevatorNumsJob;

	@Autowired
	private ElevatorDataReportJob elevatorReport;

	@Autowired
	private IFeiShuElevatorService feiShuElevatorService;

	@Autowired
	private GalaxyMaintainCustomerJob maintainCustomerJob;

	@Autowired
	private IFeiShuPartsService partsService;

	@Autowired
	private UserPerformanceMonthService userPerformanceMonthService;

	@GetMapping("/user/performance/month")
	public R<?> generateFeiShuUserPerformanceMonth(String month){
		userPerformanceMonthService.generateFeiShuUserPerformanceMonth(month);
		return R.data(Boolean.TRUE);
	}

	@GetMapping("/elevator/maintain/cost/month")
	public R<?> generateFeiShuElevatorMaintainCostMonth(String month){
		userPerformanceMonthService.generateFeiShuElevatorMaintainCostMonth(month);
		userPerformanceMonthService.generateFeiShuElevatorPlanMonth(month);
		return R.data(Boolean.TRUE);
	}

	@GetMapping("/test/elevator/pool")
	public String test() throws IOException {
		pool.testGovernmentElevatorPool();
		return "success";
	}

	/**
	 * 梯池失败本
	 * @return String 没有实际意义
	 */
	@GetMapping("/test/galaxy/elevator/pool/failure")
	public String testGalaxyElevatorPoolFailure() {
		pool.governmentUnMarkCopy();
		return "success";
	}

	/**
	 * 梯池失败
	 * @return String 没有实际意义
	 */
	@GetMapping("/galaxy/elevator/pool/failure")
	public String galaxyElevatorPoolFailure() {
		pool.governmentUnMark();
		return "success";
	}

	@GetMapping("/test/galaxy/track")
	public String testGalaxyTrack() {
		track.testUpdateTrack();
		return "success";
	}

	@GetMapping("/test/feishu/document")
	private void testUpdateMaintenancePersonnel(){
		job.testUpdateMaintenancePersonnel();
	}

	@GetMapping("/test/maintain/customerV1")
	private void testUpdateMaintainCustomerV1(){
		maintainCustomerJob.testUpdateMaintainCustomerV1();
	}

	@GetMapping("/test/maintain/customerV2")
	private void testUpdateMaintainCustomerV2(){
		maintainCustomerJob.testUpdateMaintainCustomerV2();
	}

	/**
	 * 测试表格手动执行接口：少维配件
	 */
	@GetMapping("/test/update/parts/byHand")
	public void testUpdatePartsByHand(){
		partsService.updatePartsMessageByPlanIdCopy();
	}

	/**
	 * 正式表格手动执行接口：少维配件
	 */
	@GetMapping("/update/parts/byHand")
	public void updatePartsByHand(){
		partsService.updatePartsMessageByPlanIdOriginal();
	}

	/**
	 * 正式表格手动执行接口：政府银河电梯池
	 */
	@GetMapping("/update/government/elevator/pool/byHand")
	public String updateGovernmentElevatorPoolByHand() {
		pool.governmentElevatorPool();
		return "success";
	}

	/**
	 * 正式表格手动执行接口：银河排期
	 */
	@GetMapping("/update/galaxy/track/byHand")
	public String updateGalaxyTrackByHand() {
		track.updateTrack();
		return "success";
	}

	/**
	 * 正式表格手动执行接口：维保人员
	 */
	@GetMapping("/update/maintenance/personnel/byHand")
	public String updateMaintenancePersonnelByHand() {
		job.updateMaintenancePersonnel();
		return "success";
	}

	/**
	 * 正式表格手动执行接口：自动扶梯/曳引梯检验报告
	 */
	@GetMapping("/update/elevator/data/report/byHand")
	public String updateElevatorDataReportByHand() {
		elevatorReport.updateElevatorDataReport();
		return "success";
	}

	/**
	 * 正式表格手动执行接口：电梯识别码
	 */
	@GetMapping("/update/elevator/num/byHand")
	public String updateElevatorNumByHand() {
		elevatorNumsJob.galaxyElevatorNumsJob();
		return "success";
	}

	/**
	 * 正式表格手动执行接口：在保项目电梯
	 */
	@GetMapping("/update/project/elevator/info/byHand")
	public String updateProjectElevatorInfoByHand() {
		feiShuElevatorService.updateProjectElevatorInfo();
		return "success";
	}

	/**
	 * 正式表格手动执行接口：维保客户
	 */
	@GetMapping("/update/maintain/customer/byHand")
	public String updateMaintainCustomerByHand() {
		maintainCustomerJob.updateMaintainCustomerV1();
		return "success";
	}



}
